/*
 * @Author: 老刘
 * @Date: 2020-04-29 15:51:38
 * @Description: 垂直导航
 */
const app = getApp();
Page({
	data: {
		tabIndex: 0,
		activeIndex: 0,
		tabNavTop: 0,
		list: [],
		isLoad: true
	},
	onLoad () {
		let list = [{}];
		for (let i = 0; i < 30; i++) {
			list[i] = {};
		}
		this.setData({
			list: list
		});
	},
	handleTabSelect (e) {
		this.setData({
			tabIndex: e.currentTarget.dataset.index,
			activeIndex: 0,
			tabNavTop: e.currentTarget.dataset.index * 50
		});
	},
	scrollContent (e) {
		let that = this;
		let list = this.data.list;
		let tabHeight = 0;
		if (this.data.isLoad) {
			for (let i = 0; i < list.length; i++) {
				let view = wx.createSelectorQuery().select('#main-' + i);
				view.fields({
					size: true
				}, data => {
					list[i].top = tabHeight;
					tabHeight = tabHeight + data.height;
					list[i].bottom = tabHeight;
				}).exec();
			}
			that.setData({
				isLoad: false,
				list: list
			});
		}
	}
});
